package com.zhiyou100.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {
    @RequestMapping("/login")
    public String login(String username,String password){
        //使用Shiro登陆进行认证授权
        Subject subject = SecurityUtils.getSubject();
        try {
            subject.login(new UsernamePasswordToken(username,password));
            System.out.println("登陆成功!");
            return "forward:success.jsp";
        }catch (AuthenticationException e){
            System.out.println("用户名或密码错误");
        }
        return "forward:index.jsp";
    }
    @RequestMapping("/user/delete")
    public String delete(){
        System.out.println("执行删除操作");
        return "redirect:/www.baidu.com";//TODO

    }
}
